import { Component, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core';
import { ApiSystemService } from '../../../../api/system/api-system.service';
import { FormBuilder, FormGroup, FormControl } from '@angular/forms';
import { NzMessageService } from 'ng-zorro-antd';

@Component({
  selector: 'sda-category-form',
  templateUrl: './category-form.component.html',
  styleUrls: ['./category-form.component.scss'],
})
export class CategoryFormComponent implements OnInit, OnChanges {

  // tslint:disable-next-line:no-input-rename
  @Input('category')
  category_name = '';

  category_items: { name: string; form: FormGroup; controls: { key: string }[]; }[] = [];

  // 系统表单项
  system_forms: FormGroup[];

  constructor(
    private apiService: ApiSystemService,
    private fb: FormBuilder,
    private messageService: NzMessageService
  ) { }

  ngOnInit() {
  }

  ngOnChanges(changes: SimpleChanges) {
    if (changes.category_name.currentValue === '') { return; }
    this.fetchSystemCategoryDetail(changes.category_name.currentValue);
  }

    /**
   * 获取系统item详情
   *
   * @param {string} category
   * @memberof CategoryFormComponent
   */
  fetchSystemCategoryDetail(category: string) {
    console.log(category)
    this.apiService.getSystemDetail(category).subscribe(res=> {
      // this.category_items = this.initFormInstance(res.dat);
    })
  }




  

}
